<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');

/**
 * Contao Open Source CMS
 * Copyright (C) 2005-2011 Leo Feyer
 *
 * Formerly known as TYPOlight Open Source CMS.
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program. If not, please visit the Free
 * Software Foundation website at <http://www.gnu.org/licenses/>.
 *
 * PHP version 5
 * @copyright  2012 Andreas Koob 
 * @author     Andreas Koob 
 * @package    piwik_analyser 
 * @license    LGPL 
 * @filesource
 */


/**
 * Class piwik_analyser_module_sitesmanager
 *
 * @copyright  2012 Andreas Koob 
 * @author     Andreas Koob 
 * @package    Controller
 */
class piwik_analyser_module_sitesmanager extends frontend
{
	private $functions;
	
	public function __construct()
	{
		$this->import('Database');
		$this->import('Input');
		$this->functions = new piwik_analyser_functions();
	}
	
	public function getFunctions($currentFunction)
	{
		$strFunctions='';
		$strFunctions.='<option value="sitesmanager.getjavascripttag"';if($currentFunction=='sitesmanager.getjavascripttag'){$strFunctions.=' selected="selected"';}$strFunctions.='>getJavascriptTag (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsitesfromgroup"';if($currentFunction=='sitesmanager.getsitesfromgroup'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSitesFromGroup (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsitesgroups"';if($currentFunction=='sitesmanager.getsitesgroups'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSitesGroups (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsitefromid"';if($currentFunction=='sitesmanager.getsitefromid'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSiteFromId (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsiteurlsfromid"';if($currentFunction=='sitesmanager.getsiteurlsfromid'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSiteUrlsFromId (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getallsites"';if($currentFunction=='sitesmanager.getallsites'){$strFunctions.=' selected="selected"';}$strFunctions.='>getAllSites</option>';
		$strFunctions.='<option value="sitesmanager.getallsitesid"';if($currentFunction=='sitesmanager.getallsitesid'){$strFunctions.=' selected="selected"';}$strFunctions.='>getAllSitesId</option>';
		$strFunctions.='<option value="sitesmanager.getsitesidwithvisits"';if($currentFunction=='sitesmanager.getsitesidwithvisits'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSitesIdWithVisits (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsiteswithadminaccess"';if($currentFunction=='sitesmanager.getsiteswithadminaccess'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSitesWithAdminAccess (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsiteswithviewaccess"';if($currentFunction=='sitesmanager.getsiteswithviewaccess'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSitesWithViewAccess (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsiteswithatleastviewaccess"';if($currentFunction=='sitesmanager.getsiteswithatleastviewaccess'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSitesWithAtLeastViewAccess (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsitesidwithadminaccess"';if($currentFunction=='sitesmanager.getsitesidwithadminaccess'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSitesIdWithAdminAccess (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsitesidwithviewaccess"';if($currentFunction=='sitesmanager.getsitesidwithviewaccess'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSitesIdWithViewAccess (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsitesidwithatleastviewaccess"';if($currentFunction=='sitesmanager.getsitesidwithatleastviewaccess'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSitesIdWithAtLeastViewAccess (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getsitesidfromsiteurl"';if($currentFunction=='sitesmanager.getsitesidfromsiteurl'){$strFunctions.=' selected="selected"';}$strFunctions.='>getSitesIdFromSiteUrl (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.addsite"';if($currentFunction=='sitesmanager.addsite'){$strFunctions.=' selected="selected"';}$strFunctions.='>addSite (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.addsitealiasurl"';if($currentFunction=='sitesmanager.addsitealiasurl'){$strFunctions.=' selected="selected"';}$strFunctions.='>addSiteAliasUrls (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getipsforrange"';if($currentFunction=='sitesmanager.getipsforrange'){$strFunctions.=' selected="selected"';}$strFunctions.='>getIpsForRange (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.setglobalexcludedips"';if($currentFunction=='sitesmanager.setglobalexcludedips'){$strFunctions.=' selected="selected"';}$strFunctions.='>setGlobalExcludedIps (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getexcludedqueryparametersglobal"';if($currentFunction=='sitesmanager.getexcludedqueryparametersglobal'){$strFunctions.=' selected="selected"';}$strFunctions.='>getExcludedQueryParametersGlobal (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.setglobalexcludedqueryparameters"';if($currentFunction=='sitesmanager.setglobalexcludedqueryparameters'){$strFunctions.=' selected="selected"';}$strFunctions.='>setGlobalExcludedQueryParameters (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getexcludedipsglobal"';if($currentFunction=='sitesmanager.getexcludedipsglobal'){$strFunctions.=' selected="selected"';}$strFunctions.='>getExcludedIpsGlobal (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getdefaultcurrency"';if($currentFunction=='sitesmanager.getdefaultcurrency'){$strFunctions.=' selected="selected"';}$strFunctions.='>getDefaultCurrency (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.setdefaultcurrency"';if($currentFunction=='sitesmanager.setdefaultcurrency'){$strFunctions.=' selected="selected"';}$strFunctions.='>setDefaultCurrency (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getdefaulttimezone"';if($currentFunction=='sitesmanager.getdefaulttimezone'){$strFunctions.=' selected="selected"';}$strFunctions.='>getDefaultTimezone (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.setdefaulttimezone"';if($currentFunction=='sitesmanager.setdefaulttimezone'){$strFunctions.=' selected="selected"';}$strFunctions.='>setDefaultTimezone (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.updatesite"';if($currentFunction=='sitesmanager.updatesite'){$strFunctions.=' selected="selected"';}$strFunctions.='>updateSite (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getcurrencylist"';if($currentFunction=='sitesmanager.getcurrencylist'){$strFunctions.=' selected="selected"';}$strFunctions.='>getCurrencyList (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getcurrencysymbols"';if($currentFunction=='sitesmanager.getcurrencysymbols'){$strFunctions.=' selected="selected"';}$strFunctions.='>getCurrencySymbols (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.gettimezonelist"';if($currentFunction=='sitesmanager.gettimezonelist'){$strFunctions.=' selected="selected"';}$strFunctions.='>getTimezoneList (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getuniquesitetimezones"';if($currentFunction=='sitesmanager.getuniquesitetimezones'){$strFunctions.=' selected="selected"';}$strFunctions.='>getUniqueSiteTimezones (Not implemented)</option>';
		$strFunctions.='<option value="sitesmanager.getpatternmatchsites"';if($currentFunction=='sitesmanager.getpatternmatchsites'){$strFunctions.=' selected="selected"';}$strFunctions.='>getPatternMatchSites (Not implemented)</option>';
		return $strFunctions;
	}
	
	public function getQueryCode($function)
	{
		switch($function)
		{
			case 'sitesmanager.getjavascripttag':
				break;
			case 'sitesmanager.getsitesfromgroup':
				break;
			case 'sitesmanager.getsitesgroups':
				break;
			case 'sitesmanager.getsitefromid':
				break;
			case 'sitesmanager.getsiteurlsfromid':
				break;
			case 'sitesmanager.getallsites':
				//No code required
				return '';
				break;
			case 'sitesmanager.getallsitesid':
				//No code required
				return '';
				break;
			case 'sitesmanager.getsitesidwithvisits':
				break;
			case 'sitesmanager.getsiteswithadminaccess':
				break;
			case 'sitesmanager.getsiteswithviewaccess':
				break;
			case 'sitesmanager.getsiteswithatleastviewaccess':
				break;
			case 'sitesmanager.getsitesidwithadminaccess':
				break;
			case 'sitesmanager.getsitesidwithviewaccess':
				break;
			case 'sitesmanager.getsitesidwithatleastviewaccess':
				break;
			case 'sitesmanager.getsitesidfromsiteurl':
				break;
			case 'sitesmanager.addsite':
				break;
			case 'sitesmanager.addsitealiasurl':
				break;
			case 'sitesmanager.getipsforrange':
				break;
			case 'sitesmanager.setglobalexcludedips':
				break;
			case 'sitesmanager.getexcludedqueryparametersglobal':
				break;
			case 'sitesmanager.setglobalexcludedqueryparameters':
				break;
			case 'sitesmanager.getexcludedipsglobal':
				break;
			case 'sitesmanager.getdefaultcurrency':
				break;
			case 'sitesmanager.setdefaultcurrency':
				break;
			case 'sitesmanager.getdefaulttimezone':
				break;
			case 'sitesmanager.setdefaulttimezone':
				break;
			case 'sitesmanager.updatesite':
				break;
			case 'sitesmanager.getcurrencylist':
				break;
			case 'sitesmanager.getcurrencysymbols':
				break;
			case 'sitesmanager.gettimezonelist':
				break;
			case 'sitesmanager.getuniquesitetimezones':
				break;
			case 'sitesmanager.getpatternmatchsites':
				break;
			default:
				break;
		}
	}
	
	public function processFunction($function)
	{
		switch($function)
		{
			case 'sitesmanager.getjavascripttag':
				break;
			case 'sitesmanager.getsitesfromgroup':
				break;
			case 'sitesmanager.getsitesgroups':
				break;
			case 'sitesmanager.getsitefromid':
				break;
			case 'sitesmanager.getsiteurlsfromid':
				break;
			case 'sitesmanager.getallsites':
				$account=$this->functions->getAccountDetails($this->Input->post('account'));
				$url=$account['url'];
				$url.='/?module=API';
				$url.='&method=SitesManager.getAllSites';
				$url.='&format=php';
				$url.='&token_auth=' . $account['token'];
				$fetched = file_get_contents($url);
				$arrResult=array(
					'query'=>$url,
					'result'=>unserialize($fetched)
				);
				return $arrResult;
				break;
			case 'sitesmanager.getallsitesid':
				$account=$this->functions->getAccountDetails($this->Input->post('account'));
				$url=$account['url'];
				$url.='/?module=API';
				$url.='&method=SitesManager.getAllSitesId';
				$url.='&format=php';
				$url.='&token_auth=' . $account['token'];
				$fetched = file_get_contents($url);
				$arrResult=array(
					'query'=>$url,
					'result'=>unserialize($fetched)
				);
				return $arrResult;
				break;
			case 'sitesmanager.getsitesidwithvisits':
				break;
			case 'sitesmanager.getsiteswithadminaccess':
				break;
			case 'sitesmanager.getsiteswithviewaccess':
				break;
			case 'sitesmanager.getsiteswithatleastviewaccess':
				break;
			case 'sitesmanager.getsitesidwithadminaccess':
				break;
			case 'sitesmanager.getsitesidwithviewaccess':
				break;
			case 'sitesmanager.getsitesidwithatleastviewaccess':
				break;
			case 'sitesmanager.getsitesidfromsiteurl':
				break;
			case 'sitesmanager.addsite':
				break;
			case 'sitesmanager.addsitealiasurl':
				break;
			case 'sitesmanager.getipsforrange':
				break;
			case 'sitesmanager.setglobalexcludedips':
				break;
			case 'sitesmanager.getexcludedqueryparametersglobal':
				break;
			case 'sitesmanager.setglobalexcludedqueryparameters':
				break;
			case 'sitesmanager.getexcludedipsglobal':
				break;
			case 'sitesmanager.getdefaultcurrency':
				break;
			case 'sitesmanager.setdefaultcurrency':
				break;
			case 'sitesmanager.getdefaulttimezone':
				break;
			case 'sitesmanager.setdefaulttimezone':
				break;
			case 'sitesmanager.updatesite':
				break;
			case 'sitesmanager.getcurrencylist':
				break;
			case 'sitesmanager.getcurrencysymbols':
				break;
			case 'sitesmanager.gettimezonelist':
				break;
			case 'sitesmanager.getuniquesitetimezones':
				break;
			case 'sitesmanager.getpatternmatchsites':
				break;
			default:
				break;
		}
	}
}

?>